package com.example.appbarlayoutdemo.adapter;

import android.graphics.Paint;
import android.graphics.Typeface;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.appbarlayoutdemo.R;
import com.example.appbarlayoutdemo.bean.DataListBean;
import com.example.appbarlayoutdemo.bean.HomeLabelBean;

import java.util.List;

/**
 * 作者:  njb
 * 时间:  2019/4/30 15:35
 * 描述:  品牌新品列表
 */

public class BrandCategoryAdapter extends BaseQuickAdapter<DataListBean, BaseViewHolder> {
    private TextView tv_new_discount,tvPrice;
    private ImageView iv_new_shop;

    public BrandCategoryAdapter(@Nullable List<DataListBean> data) {
        super(R.layout.item_new_brand, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, DataListBean item) {
        if (item == null) {
            return;
        }
        tv_new_discount = helper.getView(R.id.tv_new_discount);
        iv_new_shop = helper.getView(R.id.iv_new_shop);
        tvPrice = helper.getView(R.id.tv_new_price);
        if (item.getPictureUrl() != null && !item.getPictureUrl().equals("")) {
            Glide.with(mContext).load(item.getPictureUrl()).into(iv_new_shop);
        }
        if (item.getSellingPrice() != null && !item.getSellingPrice().equals("")) {
            tvPrice.setText("￥" + item.getSellingPrice());
        } else {
            tvPrice.setText("");
        }
        if (item.getOfficialPrice() != null && !item.getOfficialPrice().equals("")) {
            tv_new_discount.setText("￥" + item.getOfficialPrice());
            tv_new_discount.getPaint().setAntiAlias(true);//抗锯齿
            tv_new_discount.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG); //中划线
        } else {
            tv_new_discount.setText("");
        }
        //Typeface typefacehef = Typeface.createFromAsset(mContext.getAssets(), "Helvetica.ttf");
        //tvPrice.setTypeface(typefacehef);
        //tv_new_discount.setTypeface(typefacehef);
    }
}
